﻿using SalesSys.DAL.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SalesSys.Site.Models
{
    /// <summary>
    /// 锁价单模型类
    /// </summary>
    public class LockOrderDto
    {
        /// <summary>
        /// 客户
        /// </summary>
        public Guid CustomerId { get; set; }

        /// <summary>
        /// 供应商
        /// </summary>
        public Guid SupplierId { get; set; }

        /// <summary>
        /// 标件户头
        /// </summary>
        public Guid AccountId { get; set; }

        ///// <summary>
        ///// 是否标件
        ///// </summary>
        //public bool IsStandard { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }

        /// <summary>
        /// 供应商
        /// </summary>
        public Guid ProviderId { get; set; }

        /// <summary>
        /// 是否商品锁价
        /// </summary>
        public bool IsGoodsLock { get; set; }

        /// <summary>
        /// 商品历史信息
        /// </summary>
        public Guid? depotCommodityRecordId { get; set; }

        /// <summary>
        /// 是否议价
        /// </summary>
        public bool IsBargaining { get; set; }

        ///// <summary>
        ///// 每吨优惠合计,优惠使用负值表示
        ///// </summary>
        //public decimal UnitDiscount { get; set; }

        /// <summary>
        /// 总价
        /// </summary>
        public decimal Total { get; set; }

        /// <summary>
        /// 是否审批中，审批流程中会包含某个计划单编号
        /// </summary>
        public bool IsApproval { get; set; }

        /// <summary>
        /// 是否暂停
        /// </summary>
        public bool IsPause { get; set; }

        /// <summary>
        /// 申请单价优惠金额,优惠使用负值表示
        /// </summary>
        public decimal ApplyDiscount { get; set; }

        /// <summary>
        /// Dto转锁价单实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public LockOrder ToEntity(LockOrder entity = null)
        {
            if (entity == null)
            {
                entity = new LockOrder();
            }
            entity.IsGoodsLock = this.IsGoodsLock;
            //entity.UnitDiscount = this.UnitDiscount;
            entity.Total = this.Total;
            //entity.IsStandard = this.IsStandard;
            entity.Remarks = this.Remarks;
            if (this.ApplyDiscount != 0.0M)
                entity.ApplyDiscount = this.ApplyDiscount;
            return entity;
        }
    }
}